package com.edu.exam.entity.personnel.student;

import com.edu.exam.enums.student.EnrollmentStatus;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * 学籍状态变更历史实体类
 * [所属模块] F-04 学籍管理模块
 * 对应数据库表：enrollment_status_history
 */
@Entity
@Table(name = "enrollment_status_history")
public class EnrollmentStatusHistory {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @NotNull(message = "学籍ID不能为空")
    @Column(name = "enrollment_id", nullable = false)
    private Long enrollmentId;

    @Enumerated(EnumType.STRING)
    @Column(name = "from_status", length = 20)
    private EnrollmentStatus fromStatus;

    @NotNull(message = "目标状态不能为空")
    @Enumerated(EnumType.STRING)
    @Column(name = "to_status", nullable = false, length = 20)
    private EnrollmentStatus toStatus;

    @NotNull(message = "变更日期不能为空")
    @Column(name = "change_date", nullable = false)
    private LocalDate changeDate;

    @NotBlank(message = "变更原因不能为空")
    @Size(max = 500, message = "变更原因长度不能超过500个字符")
    @Column(name = "change_reason", nullable = false, length = 500)
    private String changeReason;

    @NotBlank(message = "变更类型不能为空")
    @Size(max = 50, message = "变更类型长度不能超过50个字符")
    @Column(name = "change_type", nullable = false, length = 50)
    private String changeType;

    @Column(name = "created_time", nullable = false, updatable = false)
    private LocalDateTime createdTime;

    @Size(max = 50, message = "创建人长度不能超过50个字符")
    @Column(name = "created_by", length = 50)
    private String createdBy;
}